package com.ls.modules.sys.controller;

import com.ls.base.utils.PageUtils;
import com.ls.base.utils.R;
import com.ls.common.baseClass.BackStageController;
import com.ls.modules.sys.biz.manager.TestManager;
import com.ls.modules.sys.biz.manager.TestMongoService;
import com.ls.modules.sys.biz.manager.TestService;
import com.ls.modules.sys.dal.mongodb.entity.PersonEntity;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: xiaosu
 * @date: 2018-09-17  12:18
 */

@RestController
@RequestMapping("/")
public class TestController  extends BackStageController {


    @Autowired
    private TestManager  testManager;

    @Autowired
    private TestService  testService;

    @Autowired
    private TestMongoService  testMongoService;


    @RequestMapping("/")
    public R  index(){


        testManager.insertEntity();
        logger.info("xiaosu henshuai");
        return R.ok();

    }


    @RequestMapping("/index")
    public R  index2(){


        testService.insertEntity();
        logger.info("xiaosu henshuai");
        return R.ok();

    }

    @ApiOperation("ceshi3")
    @RequestMapping(value = "/index3",method = RequestMethod.GET)
    public R  index3(){
        Map<String,Object>  map=new HashMap<>();

        map.put("page","1");
        map.put("limit","10");
        map.put("name","xiao");
        PageUtils  page=testService.queryPage(map);

//        testService.insertEntity();
        logger.info("xiaosu henshuai");
        return R.ok().put("page",page);

    }

    @ApiOperation("mongodb")
    @RequestMapping(value = "/testM",method = RequestMethod.POST)
    public R  testM(@RequestBody PersonEntity personEntity){


       testMongoService.insertEntity();
        logger.info("xiaosu henshuai");
        return R.ok();

    }

}
